package com.mingqi.enetconnected.view;

import android.content.Context;
import android.util.AttributeSet;

import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.util.resource.ResourceUtils;

public class BorderRadioButton extends android.support.v7.widget.AppCompatRadioButton {
    public BorderRadioButton(Context context) {
        super(context);
    }

    public BorderRadioButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BorderRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void setChecked(boolean checked) {
        setTextColor(checked ? ResourceUtils.getColor(R.color.colorPrimary) : ResourceUtils.getColor(R.color.color_black_ff333333));
        super.setChecked(checked);
    }

    @Override
    public void setEnabled(boolean enabled) {
        if (!enabled) {
            setTextColor(ResourceUtils.getColor(R.color.color_grey_999999));
            setBackgroundResource(R.drawable.border_radius_grey);
        }
        super.setEnabled(enabled);
    }

    @Override
    public void toggle() {
        setChecked(!isChecked());
    }
}
